<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function foo() {

    }

    const fooProxy = new Proxy(foo, {
      apply: function (target, thisArg, args) {
        console.log("监听: 监听函数的调用")
        return target.apply(thisArg, args)
      },
      construct: function (target, args) {
        console.log("监听: 监听函数的new调用")
        return new target(...args)
      }
    })
    fooProxy.apply("abc", [111, 222])
    new fooProxy(111, 222)
  </script>
</body>

</html>